package com.wthink.newMain.settings.config.inner.netconfig.viewmodel


import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.R
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.databinding.FragmentNewNetconfigBinding
import com.wthink.hzgj.service.DevService
import com.wthink.newMain.settings.config.inner.netconfig.adapter.NetConfig
import com.wthink.newMain.settings.config.inner.viewmodel.NetConfigNewViewmodel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class ConfigNewListViewmodel :ViewModel(){
    val netconfigList = MutableLiveData(emptyList<NetConfig>())
    var list : ArrayList<NetConfig>? = ArrayList()


    fun getNetConfig(success: (List<NetConfig>) -> Unit){
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.getNetConfig("servers")
            if (ret is Result.Success) {
                val data = ret.data.netConfigList
                netconfigList.postValue(data)
                success(ret?.data.netConfigList)
            }
        }
    }
}